function Registerlowprofitastros()
	local entities = 	ents.GetAll( )
	for _, ent in ipairs( entities ) do
		local name = ent:GetName()
		if (name == "Mineastroids_low") then
			local flakz = ents.Create( "Astroid1" )
			if ( !flakz:IsValid() ) then return end
			flakz:SetPos(ent:GetPos())
			flakz:SetAngles(Angle(0,0,0)) 
			flakz:Spawn()
			flakz:Initialize()
			flakz:Activate()
			flakz.orginalposition = ent:GetPos()
			flakz:GetPhysicsObject():EnableGravity( false ) 
		end
	end			
end
hook.Add( "InitPostEntity", "Registerlowprofitastros", Registerlowprofitastros );  

function Astroidmined(astroid,mininglaser)
	local nextowner = servertable["entitys"][mininglaser:EntIndex()]["owner"]
	local yield = astroid.yield
	local pos = astroid:GetPos()
	local orginalposition = astroid.orginalposition
	local effectdata = EffectData()
	effectdata:SetStart( astroid:GetPos() )
	effectdata:SetOrigin( astroid:GetPos() )
	effectdata:SetScale( 30 )
	effectdata:SetMagnitude( 40 )
	effectdata:SetEntity(astroid)
	util.Effect( "big_explosion", effectdata )
	astroid:Remove()
	timer.Create("Respawn" .. tostring(pos),60,1,Respawnastro,orginalposition) 
	for var=1, yield, 1 do 
		local flakz = ents.Create( "Astroid1_result" )
		if ( !flakz:IsValid() ) then return end
		flakz.valid = true
		flakz:SetPos(pos)
		flakz:SetAngles(Angle(0,0,0)) 
		flakz:Spawn()
		flakz:Initialize()
		flakz:Activate()
		flakz:GetPhysicsObject():EnableGravity( false ) 
		local entid = flakz:EntIndex( )
		servertable["entitys"][entid] = {}
		servertable["entitys"][entid]["owner"] = nextowner
		timer.Create("stop" .. tostring(flakz),1,1,freezethem,flakz) 
	end
end

function freezethem(ent)
local physobj= ent:GetPhysicsObject( )
	physobj:EnableMotion(  false )
end

function Respawnastro(pos)
	local check = ents.FindInSphere( pos, 500 )
	local doit = true
	for _, ent in ipairs(check) do
		local class = ent:GetClass()
		if (class == "prop_physics") or (class == "Astroid1") or (class == "Shipcore")then
			doit = false
			break
		end
	end
	if doit then
		local flakz = ents.Create( "Astroid1" )
		if ( !flakz:IsValid() ) then return end
		flakz:SetPos(pos)
		flakz:SetAngles(Angle(0,0,0)) 
		flakz:Spawn()
		flakz:Initialize()
		flakz:Activate()
		flakz.orginalposition = pos
		flakz:GetPhysicsObject():EnableGravity( false ) 
	else
		timer.Create("Respawn" .. tostring(pos),60,1,Respawnastro,orginalposition)
	end
end 